package study.sql

import org.apache.spark.SparkConf
import org.apache.spark.sql.SparkSession

/**
 * @author zh
 * @date 2021/5/26 17:48
 */
object TestSparkSql01 {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local").setAppName("sparksql")

    val spark = SparkSession.builder().config(sparkConf).getOrCreate()
    // 隐式转换
    import spark.implicits._

    val dataFrame = spark.read.json("data/user.json")

    dataFrame.show()

    val dfToDs = dataFrame.as[User]
    dfToDs.show()


    spark.close()
  }
}

case class User(name:String,age:Long)
